package com.uniapp.java.uniappjava.controller;

import com.uniapp.java.uniappjava.pojo.Production;
import com.uniapp.java.uniappjava.service.ProductionService;
import com.uniapp.java.uniappjava.utils.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author lsy_server
 */
@RestController
@RequestMapping("production")
@Api(value = "作品")
public class ProductionController {
    @Autowired
    private ProductionService productionService;

    @GetMapping
    public Result getAll(@RequestParam String authorId,
                         @RequestParam(defaultValue = "1") Integer page,
                         @RequestParam(defaultValue = "4") Integer limit,
                         @RequestParam(defaultValue = "addTime") String order,
                         @RequestParam(defaultValue = "desc") String sort) {
        return Result.ok(productionService.queryProductions(authorId,page,limit,order,sort));
    }

    @PostMapping
    public Result add(@RequestBody Production production){
        return Result.ok(productionService.save(production));
    }
}
